<?php

namespace App\Trip\Plane;

use Exception;
use Illuminate\Support\Str;

class CarrierCode
{
    /**
     * 通过航班号获取
     * @param string|null $flight_no
     * @return string
     * @throws Exception
     */
    static function getCarrierCode(?string $flight_no): string
    {
        if (!$flight_no) {
            throw new Exception('航班号参数错误');
        }
        return strtoupper(Str::substr($flight_no, 0, 2));
    }
}